import server from "../util/request.js";

export function findAll(){
    return server({
        url:'/category/findAll2',
        method:'GET'
    })
}

export function findByIdApi(categoryId){
    return server({
        url:`/category/findById/${categoryId}`,
        method:'GET'
    })
}

export function updateApi(data){
    return server({
        url:'/category/update',
        method:'PUT',
        data:data
    })
}
export function updateStatusApi(data){
    return server({
        url:'/category/updateStatus',
        method:'PUT',
        data:data
    })
}
export function deleteApi(categoryId){
    return server({
        url:`/category/delete/${categoryId}`,
        method:'DELETE'
    })
}
export function addApi(data){
    return server({
        url:'/category/add',
        method:'POST',
        data:data
    })
}
export function addSubCategory(data){
    return server({
        url:`/category/addSubCategory/${data.name}/${data.typeId}`,
        method:'POST',
        data:{name:data.name,typeId:data.categoryId}
    })
}
export function findByName(name){
    return server({
        url:`/category/findByName/${name}`,
        method:'GET'
    })
}
export function findAll2(){
    return server({
        url:'/category',
        method:'GET'
    })
}